package com.tsu.mall.admin.service.impl;

import com.tsu.mall.admin.mapper.CountMapper;
import com.tsu.mall.admin.service.ICountService;
import com.tsu.mall.common.VO.ResultVO;
import com.tsu.mall.common.entity.Bill;
import com.tsu.mall.common.entity.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CountServiceImpl implements ICountService {
    @Autowired
    private CountMapper countMapper;
    @Override
    public ResultVO countList(String source, String sourceJoinTime) {
        ResultVO vo = new ResultVO();
        String[] arr=sourceJoinTime.split("~");
        String firstTime=arr[0].trim();
        String secondTime = arr[1].trim();
        if (source.equals("会员")) {
            source = "member";
            List<Member> list=countMapper.doCountList(source,firstTime,secondTime);
            vo.setData(list);
            return vo;
        }else if (source.equals("订单")){
            source = "bill";
            List<Bill> list=countMapper.doBillCountList(source,firstTime,secondTime);
            vo.setData(list);
        }
        return vo;
    }



}
